package com.boot.main.controller;

import com.boot.main.entity.CcomDict;

import com.boot.main.service.IDictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping(value = "/v1/api")
@Api(tags = "字典模块")
public class DictController {
    @Resource
    private IDictService dictService;

    @RequestMapping(value="/dicts", method = RequestMethod.GET)
    @ApiOperation(value = "获取字典列表")
    public Object getDicts(@RequestParam("page") Integer page, @RequestParam("limit") Integer limit, @RequestParam("name") String name){
        return dictService.getDicts(page, limit, name);
    }

    @RequestMapping(value="/dict", method = RequestMethod.POST)
    @ApiOperation(value = "保存字典")
    public Object savePermission(@RequestBody CcomDict dict){
        return dictService.saveDict(dict);
    }

    @RequestMapping(value="/dict/{id}", method = RequestMethod.PUT)
    @ApiOperation(value="更新字典")
    public Object updatePermission(@RequestBody CcomDict dict){
        return dictService.updateDict(dict);
    }

    @RequestMapping(value="/dict/{id}", method = RequestMethod.DELETE)
    @ApiOperation(value="删除字典")
    public Object deletePermission(@PathVariable long id){
        return dictService.deleteDict(id);
    }
}
